package com.bxl.netty.rpc.common.util;



import java.lang.reflect.Constructor;
import com.bxl.netty.rpc.common.context.Context;

/**
 * <>
 *
 * @author baixl
 * @date 2021/3/6
 */
public class HandlerFactory<S> {
    protected Class clazz;

    public HandlerFactory(Class clazz) {
        this.clazz = clazz;
    }

    public <T> T getBean(S context) {
        try {
            Constructor constructor = clazz.getConstructor(Context.class);
            return (T)constructor.newInstance(context);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        
    }
}
